package com.feihong.txgw.utils.greendao;

import com.feihong.txgw.app.App;
import com.feihong.txgw.greendao.gen.DaoMaster;
import com.feihong.txgw.greendao.gen.DaoSession;
import com.feihong.txgw.greendao.gen.GreenDaoHelper;
import com.feihong.txgw.greendao.gen.ShopCarGoodsModelDao;

/**
 * @Author wangziheng
 * @ProjectName txgw_app
 * @ClassName GreenDaoOperateHelper
 * @package com.feihong.txgw.utils.manage
 * @data 2018/5/2 16:50
 * @Describe
 * @Change
 */
public class GreenDaoManager {

    private static DaoMaster mDaoMaster;
    private static DaoSession mDaoSession;
    private static DaoMaster.OpenHelper mOpenHelper;
    private static ShopCarGoodsModelDao mShopcarGoodsModelDao;
    public static ShopCarGoodsModelDao getShopCarGoodsModelDao(){
        if(mShopcarGoodsModelDao == null){
            synchronized (GreenDaoManager.class){
                if(mShopcarGoodsModelDao == null){
                    mOpenHelper = new GreenDaoHelper(App.getApp().getApplication());
                    mDaoMaster = new DaoMaster(mOpenHelper.getWritableDb());
                    mDaoSession = mDaoMaster.newSession();
                    mShopcarGoodsModelDao = mDaoSession.getShopCarGoodsModelDao();
                }
            }
        }
        return mShopcarGoodsModelDao;
    }
}
